﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.RobotTracking.CCoRTRobotTrackingToggleCmd
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using EngineeringInternalExtension;
using System;
using System.Resources;
using Tecnomatix.Engineering;


namespace DnProcessSimulateCommands.RobotTracking;

public class CCoRTRobotTrackingToggleCmd : TxToggleButtonCommand
{
  private CApRTRobotTrackingModeMgr m_modeMgr;
  private bool m_pressed;
  private CApRTRobotTrackingToggleCmdEnabler m_enabler;

  public CCoRTRobotTrackingToggleCmd()
  {
    this.m_modeMgr = new CApRTRobotTrackingModeMgr(this);
    this.m_pressed = false;
    this.m_enabler = new CApRTRobotTrackingToggleCmdEnabler();
  }

  public bool Pressed
  {
    get => this.m_pressed;
    set => this.m_pressed = value;
  }

  public virtual void Execute(object cmdParams)
  {
    try
    {
      this.m_modeMgr.ActivateRobotTracking(!base.Push);
      this.ToggleState();
      new TxCommandManager().NotifyCommandExecuted((ITxCommand) this);
    }
    catch (Exception ex)
    {
    }
  }

  public virtual bool Licensed => TxCommandLicenser.RobotTrackingModeLicense;

  public virtual bool Connect()
  {
    this.m_modeMgr.Init();
    return true;
  }

  public virtual void Disconnect() => this.m_modeMgr.Uninit();

  public virtual string Category
  {
    get => this.GetResourceManager().GetString("CMD_ROBOT_TRACKING_TOGGLE_CATEGORY");
  }

  public virtual string Name
  {
    get => this.GetResourceManager().GetString("CMD_ROBOT_TRACKING_TOGGLE_NAME");
  }

  public virtual string Bitmap => "RobotTracking.Res.RTRobotTrackingToggleCmdIcon.bmp";

  public virtual string Description
  {
    get => this.GetResourceManager().GetString("CMD_ROBOT_TRACKING_TOGGLE_DESCRIPTION");
  }

  public virtual ITxCommandEnabler CommandEnabler => (ITxCommandEnabler) this.m_enabler;

  public virtual bool Push => this.Pressed;

  public void ToggleState() => this.Pressed = !this.Pressed;

  internal bool ShouldEnable
  {
    get => this.m_enabler.ShouldEnable;
    set => this.m_enabler.ShouldEnable = value;
  }

  private ResourceManager GetResourceManager()
  {
    return new ResourceManager("DnProcessSimulateCommands.RobotTracking.Res.ResourceTable", ((object) this).GetType().Assembly);
  }
}
